MoreExam
1. Question Content...
EXPLANATION
Answer: X - EXPLANATION Content.
Question1: CORRECT TEXTProblem Scenario 41 : You have been given below code snippet.val aul = sc.parallelize(List (("a" , Array(1,2)), ("b" , Array(1,2)))) val au2 = sc.parallelize(List (("a" , Array(3)), ("b" , Array(2))))Apply the Spark method, which will generate below output.Array[(String, Array[lnt])] = Array((a,Array(1, 2)), (b,Array(1, 2)), (a(Array(3)), (b,Array(2)))
Question2: CORRECT TEXTProblem Scenario 22 : You have been given below comma separated employee information.name,salary,sex,agealok,100000,male,29jatin,105000,male,32yogesh,134000,male,39ragini,112000,female,35jyotsana,129000,female,39valmiki,123000,male,29Use the netcat service on port 44444, and nc above data line by line. Please do the following activities.1. Create a flume conf file using fastest channel, which write data in hive warehouse directory, in a table called flumeemployee (Create hive table as well tor given data).2. Write a hive query to read average salary of all employees.
Question3: CORRECT TEXTProblem Scenario 24 : You have been given below comma separated employee information.Data Set:name,salary,sex,agealok,100000,male,29jatin,105000,male,32yogesh,134000,male,39ragini,112000,female,35jyotsana,129000,female,39valmiki,123000,male,29Requirements:Use the netcat service on port 44444, and nc above data line by line. Please do the following activities.1. Create a flume conf file using fastest channel, which write data in hive warehouse directory, in a table called flumemaleemployee (Create hive table as well tor given data).2. While importing, make sure only male employee data is stored.
Question4: CORRECT TEXTProblem Scenario 43 : You have been given following code snippet.val grouped = sc.parallelize(Seq(((1,"twoM), List((3,4), (5,6)))))val flattened = grouped.flatMap {A =>groupValues.map { value => B }}You need to generate following output.Hence replace A and BArray((1,two,3,4),(1,two,5,6))
Question5: CORRECT TEXTProblem Scenario 89 : You have been given below patient data in csv format, patientID,name,dateOfBirth,lastVisitDate1001,Ah Teck,1991-12-31,2012-01-201002,Kumar,2011-10-29,2012-09-201003,Ali,2011-01-30,2012-10-21Accomplish following activities.1 . Find all the patients whose lastVisitDate between current time and '2012-09-15'2 . Find all the patients who born in 20113 . Find all the patients age4 . List patients whose last visited more than 60 days ago5 . Select patients 18 years old or younger
Question6: CORRECT TEXTProblem Scenario 33 : You have given a files as below.spark5/EmployeeName.csv (id,name)spark5/EmployeeSalary.csv (id,salary)Data is given below:EmployeeName.csvE01,LokeshE02,BhupeshE03,AmitE04,RatanE05,DineshE06,PavanE07,TejasE08,SheelaE09,KumarE10,VenkatEmployeeSalary.csvE01,50000E02,50000E03,45000E04,45000E05,50000E06,45000E07,50000E08,10000E09,10000E10,10000Now write a Spark code in scala which will load these two tiles from hdfs and join the same, and produce the (name.salary) values.And save the data in multiple tile group by salary (Means each file will have name of employees with same salary). Make sure file name include salary as well.
Question7: CORRECT TEXTProblem Scenario 77 : You have been given MySQL DB with following details.user=retail_dbapassword=clouderadatabase=retail_dbtable=retail_db.orderstable=retail_db.order_itemsjdbc URL = jdbc:mysql://quickstart:3306/retail_dbColumns of order table : (orderid , order_date , order_customer_id, order_status)Columns of ordeMtems table : (order_item_id , order_item_order_ld ,order_item_product_id, order_item_quantity,order_item_subtotal,order_item_product_price)Please accomplish following activities.1. Copy "retail_db.orders" and "retail_db.order_items" table to hdfs in respective directory p92_orders and p92 order items .2 . Join these data using orderid in Spark and Python3 . Calculate total revenue perday and per order4. Calculate total and average revenue for each date. - combineByKey-aggregateByKey
Question8: CORRECT TEXTProblem Scenario 42 : You have been given a file (sparklO/sales.txt), with the content as given in below.spark10/sales.txtDepartment,Designation,costToCompany,StateSales,Trainee,12000,UPSales,Lead,32000,APSales,Lead,32000,LASales,Lead,32000,TNSales,Lead,32000,APSales,Lead,32000,TNSales,Lead,32000,LASales,Lead,32000,LAMarketing,Associate,18000,TNMarketing,Associate,18000,TNHR,Manager,58000,TNAnd want to produce the output as a csv with group by Department,Designation,State with additional columns with sum(costToCompany) and TotalEmployeeCounttShould get result likeDept,Desg,state,empCount,totalCostSales,Lead,AP,2,64000Sales.Lead.LA.3.96000Sales,Lead,TN,2,64000
Question9: CORRECT TEXTProblem Scenario 60 : You have been given below code snippet.val a = sc.parallelize(List("dog", "salmon", "salmon", "rat", "elephant"}, 3} val b = a.keyBy(_.length) val c = sc.parallelize(List("dog","cat","gnu","salmon","rabbit","turkey","woif","bear","bee"), 3) val d = c.keyBy(_.length) operation1Write a correct code snippet for operationl which will produce desired output, shown below.Array[(lnt, (String, String))] = Array((6,(salmon,salmon)), (6,(salmon,rabbit)),(6,(salmon,turkey)), (6,(salmon,salmon)), (6,(salmon,rabbit)),(6,(salmon,turkey)), (3,(dog,dog)), (3,(dog,cat)), (3,(dog,gnu)), (3,(dog,bee)), (3,(rat,dog)),(3,(rat,cat)), (3,(rat,gnu)), (3,(rat,bee)))
Question10: CORRECT TEXTProblem Scenario 11 : You have been given following mysql database details as well as other info.user=retail_dbapassword=clouderadatabase=retail_dbjdbc URL = jdbc:mysql://quickstart:3306/retail_dbPlease accomplish following.1. Import departments table in a directory called departments.2. Once import is done, please insert following 5 records in departments mysql table.Insert into departments(10, physics);Insert into departments(11, Chemistry);Insert into departments(12, Maths);Insert into departments(13, Science);Insert into departments(14, Engineering);3. Now import only new inserted records and append to existring directory . which has been created in first step.
Question11: CORRECT TEXTProblem Scenario 95 : You have to run your Spark application on yarn with each executorMaximum heap size to be 512MB and Number of processor cores to allocate on each executor will be 1 and Your main application required three values as input arguments V1V2 V3.Please replace XXX, YYY, ZZZ./bin/spark-submit -class com.hadoopexam.MyTask --master yarn-cluster--num-executors 3--driver-memory 512m XXX YYY lib/hadoopexam.jarZZZ
Question12: CORRECT TEXTProblem Scenario 21 : You have been given log generating service as below.startjogs (It will generate continuous logs)tailjogs (You can check , what logs are being generated)stopjogs (It will stop the log service)Path where logs are generated using above service : /opt/gen_logs/logs/access.logNow write a flume configuration file named flumel.conf , using that configuration file dumps logs in HDFS file system in a directory called flumel. Flume channel should have following property as well. After every 100 message it should be committed, use non-durable/faster channel and it should be able to hold maximum 1000 eventsSolution :Step 1 : Create flume configuration file, with below configuration for source, sink and channel.#Define source , sink , channel and agent,agent1 .sources = source1agent1 .sinks = sink1agent1.channels = channel1# Describe/configure source1agent1 .sources.source1.type = execagent1.sources.source1.command = tail -F /opt/gen logs/logs/access.log## Describe sinklagentl .sinks.sinkl.channel = memory-channelagentl .sinks.sinkl .type = hdfsagentl .sinks.sink1.hdfs.path = flumelagentl .sinks.sinkl.hdfs.fileType = Data Stream# Now we need to define channell property.agent1.channels.channel1.type = memoryagent1.channels.channell.capacity = 1000agent1.channels.channell.transactionCapacity = 100# Bind the source and sink to the channelagent1.sources.source1.channels = channel1agent1.sinks.sink1.channel = channel1Step 2 : Run below command which will use this configuration file and append data in hdfs.Start log service using : startjogsStart flume service:flume-ng agent -conf /home/cloudera/flumeconf -conf-file/home/cloudera/flumeconf/flumel.conf-Dflume.root.logger=DEBUG,INFO,consoleWait for few mins and than stop log service.Stop_logs
Question13: CORRECT TEXTProblem Scenario 92 : You have been given a spark scala application, which is bundled in jar named hadoopexam.jar.Your application class name is com.hadoopexam.MyTaskYou want that while submitting your application should launch a driver on one of the cluster node.Please complete the following command to submit the application.spark-submit XXX -master yarn \YYY SSPARK HOME/lib/hadoopexam.jar 10
Question14: CORRECT TEXTProblem Scenario 88 : You have been given below three filesproduct.csv (Create this file in hdfs)productID,productCode,name,quantity,price,supplierid1001,PEN,Pen Red,5000,1.23,5011002,PEN,Pen Blue,8000,1.25,5011003,PEN,Pen Black,2000,1.25,5011004,PEC,Pencil 2B,10000,0.48,5021005,PEC,Pencil 2H,8000,0.49,5021006,PEC,Pencil HB,0,9999.99,5022001,PEC,Pencil 3B,500,0.52,5012002,PEC,Pencil 4B,200,0.62,5012003,PEC,Pencil 5B,100,0.73,5012004,PEC,Pencil 6B,500,0.47,502supplier.csvsupplierid,name,phone501,ABC Traders,88881111502,XYZ Company,88882222503,QQ Corp,88883333products_suppliers.csvproductID,supplierID2001,5012002,5012003,5012004,5022001,503Now accomplish all the queries given in solution.1. It is possible that, same product can be supplied by multiple supplier. Now find each product, its price according to each supplier.2. Find all the supllier name, who are supplying 'Pencil 3B'3. Find all the products , which are supplied by ABC Traders.
Question15: CORRECT TEXTProblem Scenario 27 : You need to implement near real time solutions for collecting information when submitted in file with below information.Dataecho "IBM,100,20160104" >> /tmp/spooldir/bb/.bb.txtecho "IBM,103,20160105" >> /tmp/spooldir/bb/.bb.txtmv /tmp/spooldir/bb/.bb.txt /tmp/spooldir/bb/bb.txtAfter few minsecho "IBM,100.2,20160104" >> /tmp/spooldir/dr/.dr.txtecho "IBM,103.1,20160105" >> /tmp/spooldir/dr/.dr.txtmv /tmp/spooldir/dr/.dr.txt /tmp/spooldir/dr/dr.txtRequirements:You have been given below directory location (if not available than create it) /tmp/spooldir .You have a finacial subscription for getting stock prices from BloomBerg as well asReuters and using ftp you download every hour new files from their respective ftp site in directories /tmp/spooldir/bb and /tmp/spooldir/dr respectively.As soon as file committed in this directory that needs to be available in hdfs in/tmp/flume/finance location in a single directory.Write a flume configuration file named flume7.conf and use it to load data in hdfs with following additional properties .1 . Spool /tmp/spooldir/bb and /tmp/spooldir/dr2 . File prefix in hdfs sholuld be events3 . File suffix should be .log4 . If file is not commited and in use than it should have _ as prefix.5 . Data should be written as text to hdfs
Question16: CORRECT TEXTProblem Scenario 2 :There is a parent organization called "ABC Group Inc", which has two child companies named Tech Inc and MPTech.Both companies employee information is given in two separate text file as below. Please do the following activity for employee details.Tech Inc.txt1,Alok,Hyderabad2,Krish,Hongkong3,Jyoti,Mumbai4 ,Atul,Banglore5 ,Ishan,GurgaonMPTech.txt6 ,John,Newyork7 ,alp2004,California8 ,tellme,Mumbai9 ,Gagan21,Pune1 0,Mukesh,Chennai1 . Which command will you use to check all the available command line options on HDFS and How will you get the Help for individual command.2. Create a new Empty Directory named Employee using Command line. And also create an empty file named in it Techinc.txt3. Load both companies Employee data in Employee directory (How to override existing file in HDFS).4. Merge both the Employees data in a Single tile called MergedEmployee.txt, merged tiles should have new line character at the end of each file content.5. Upload merged file on HDFS and change the file permission on HDFS merged file, so that owner and group member can read and write, other user can read the file.6. Write a command to export the individual file as well as entire directory from HDFS to local file System.
Question17: CORRECT TEXTProblem Scenario 56 : You have been given below code snippet.val a = sc.parallelize(l to 100. 3)operation1Write a correct code snippet for operationl which will produce desired output, shown below.Array [Array [I nt]] = Array(Array(1, 2, 3,4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19, 20,21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33),Array(34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,5 6, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66),Array(67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,8 9, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100))
Question18: CORRECT TEXTProblem Scenario 20 : You have been given MySQL DB with following details.user=retail_dbapassword=clouderadatabase=retail_dbtable=retail_db.categoriesjdbc URL = jdbc:mysql://quickstart:3306/retail_dbPlease accomplish following activities.1. Write a Sqoop Job which will import "retaildb.categories" table to hdfs, in a directory name "categories_targetJob".
Question19: CORRECT TEXTProblem Scenario 10 : You have been given following mysql database details as well as other info.user=retail_dbapassword=clouderadatabase=retail_dbjdbc URL = jdbc:mysql://quickstart:3306/retail_dbPlease accomplish following.1. Create a database named hadoopexam and then create a table named departments in it, with following fields. department_id int, department_name string e.g. location should behdfs://quickstart.cloudera:8020/user/hive/warehouse/hadoopexam.db/departments2. Please import data in existing table created above from retaidb.departments into hive table hadoopexam.departments.3. Please import data in a non-existing table, means while importing create hive table named hadoopexam.departments_new
Question20: CORRECT TEXTProblem Scenario 3: You have been given MySQL DB with following details.user=retail_dbapassword=clouderadatabase=retail_dbtable=retail_db.categoriesjdbc URL = jdbc:mysql://quickstart:3306/retail_dbPlease accomplish following activities.1. Import data from categories table, where category=22 (Data should be stored in categories subset)2. Import data from categories table, where category>22 (Data should be stored in categories_subset_2)3. Import data from categories table, where category between 1 and 22 (Data should be stored in categories_subset_3)4. While importing catagories data change the delimiter to '|' (Data should be stored in categories_subset_S)5. Importing data from catagories table and restrict the import to category_name,category id columns only with delimiter as '|'6 . Add null values in the table using below SQL statement ALTER TABLE categories modify category_department_id int(11); INSERT INTO categories values(eO.NULL.'TESTING');7. Importing data from catagories table (In categories_subset_17 directory) using '|' delimiter and categoryjd between 1 and 61 and encode null values for both string and non string columns.8. Import entire schema retail_db in a directory categories_subset_all_tables
Question21: CORRECT TEXTProblem Scenario 29 : Please accomplish the following exercises using HDFS command line options.1. Create a directory in hdfs named hdfs_commands.2. Create a file in hdfs named data.txt in hdfs_commands.3. Now copy this data.txt file on local filesystem, however while copying file please make sure file properties are not changed e.g. file permissions.4. Now create a file in local directory named data_local.txt and move this file to hdfs in hdfs_commands directory.5. Create a file data_hdfs.txt in hdfs_commands directory and copy it to local file system.6. Create a file in local filesystem named file1.txt and put it to hdfs
Question22: CORRECT TEXTProblem Scenario 85 : In Continuation of previous question, please accomplish following activities.1. Select all the columns from product table with output header as below. productID AS ID code AS Code name AS Description price AS 'Unit Price'2. Select code and name both separated by ' -' and header name should be ProductDescription'.3. Select all distinct prices.4 . Select distinct price and name combination.5 . Select all price data sorted by both code and productID combination.6 . count number of products.7 . Count number of products for each code.
Question23: CORRECT TEXTProblem Scenario 18 : You have been given following mysql database details as well as other info.user=retail_dbapassword=clouderadatabase=retail_dbjdbc URL = jdbc:mysql://quickstart:3306/retail_dbNow accomplish following activities.1. Create mysql table as below.mysql --user=retail_dba -password=clouderause retail_dbCREATE TABLE IF NOT EXISTS departments_hive02(id int, department_namevarchar(45), avg_salary int);show tables;2. Now export data from hive table departments_hive01 in departments_hive02. While exporting, please note following. wherever there is a empty string it should be loaded as a null value in mysql.wherever there is -999 value for int field, it should be created as null value.
Question24: CORRECT TEXTProblem Scenario 65 : You have been given below code snippet.val a = sc.parallelize(List("dog", "cat", "owl", "gnu", "ant"), 2)val b = sc.parallelize(1 to a.count.tolnt, 2)val c = a.zip(b)operation1Write a correct code snippet for operationl which will produce desired output, shown below.Array[(String, Int)] = Array((owl,3), (gnu,4), (dog,1), (cat,2>, (ant,5))
Question25: CORRECT TEXTProblem Scenario GG : You have been given below code snippet.val a = sc.parallelize(List("dog", "tiger", "lion", "cat", "spider", "eagle"), 2) val b = a.keyBy(_.length) val c = sc.parallelize(List("ant", "falcon", "squid"), 2) val d = c.keyBy(.length)operation 1Write a correct code snippet for operationl which will produce desired output, shown below.Array[(lnt, String)] = Array((4,lion))
Question26: CORRECT TEXTProblem Scenario 16 : You have been given following mysql database details as well as other info.user=retail_dbapassword=clouderadatabase=retail_dbjdbc URL = jdbc:mysql://quickstart:3306/retail_dbPlease accomplish below assignment.1. Create a table in hive as below.create table departments_hive(department_id int, department_name string);2. Now import data from mysql table departments to this hive table. Please make sure that data should be visible using below hive command, select" from departments_hive
Question27: CORRECT TEXTProblem Scenario 82 : You have been given table in Hive with following structure (Which you have created in previous exercise).productid int code string name string quantity int price floatUsing SparkSQL accomplish following activities.1 . Select all the products name and quantity having quantity <= 20002 . Select name and price of the product having code as 'PEN'3 . Select all the products, which name starts with PENCIL4 . Select all products which "name" begins with 'P\ followed by any two characters, followed by space, followed by zero or more characters
Question28: CORRECT TEXTProblem Scenario 58 : You have been given below code snippet.val a = sc.parallelize(List("dog", "tiger", "lion", "cat", "spider", "eagle"), 2) val b = a.keyBy(_.length) operation1Write a correct code snippet for operationl which will produce desired output, shown below.Array[(lnt, Seq[String])] = Array((4,ArrayBuffer(lion)), (6,ArrayBuffer(spider)),(3,ArrayBuffer(dog, cat)), (5,ArrayBuffer(tiger, eagle}}}
Question29: CORRECT TEXTProblem Scenario 9 : You have been given following mysql database details as well as other info.user=retail_dbapassword=clouderadatabase=retail_dbjdbc URL = jdbc:mysql://quickstart:3306/retail_dbPlease accomplish following.1. Import departments table in a directory.2. Again import departments table same directory (However, directory already exist hence it should not overrride and append the results)3. Also make sure your results fields are terminated by '|' and lines terminated by '\n\
Question30: CORRECT TEXTProblem Scenario 12 : You have been given following mysql database details as well as other info.user=retail_dbapassword=clouderadatabase=retail_dbjdbc URL = jdbc:mysql://quickstart:3306/retail_dbPlease accomplish following.1. Create a table in retailedb with following definition.CREATE table departments_new (department_id int(11), department_name varchar(45), created_date T1MESTAMP DEFAULT NOW());2 . Now isert records from departments table to departments_new3 . Now import data from departments_new table to hdfs.4 . Insert following 5 records in departmentsnew table. Insert into departments_new values(110, "Civil" , null); Insert into departments_new values(111, "Mechanical" , null);Insert into departments_new values(112, "Automobile" , null); Insert into departments_new values(113, "Pharma" , null);Insert into departments_new values(114, "Social Engineering" , null);5. Now do the incremental import based on created_date column.
Question31: CORRECT TEXTProblem Scenario 86 : In Continuation of previous question, please accomplish following activities.1 . Select Maximum, minimum, average , Standard Deviation, and total quantity.2 . Select minimum and maximum price for each product code.3. Select Maximum, minimum, average , Standard Deviation, and total quantity for each product code, hwoever make sure Average and Standard deviation will have maximum two decimal values.4. Select all the product code and average price only where product count is more than or equal to 3.5. Select maximum, minimum , average and total of all the products for each code. Also produce the same across all the products.
Question32: CORRECT TEXTProblem Scenario 53 : You have been given below code snippet.val a = sc.parallelize(1 to 10, 3)operation1b.collectOutput 1Array[lnt] = Array(2, 4, 6, 8,10)operation2Output 2Array[lnt] = Array(1,2, 3)Write a correct code snippet for operation1 and operation2 which will produce desired output, shown above.
Question33: CORRECT TEXTProblem Scenario 15 : You have been given following mysql database details as well as other info.user=retail_dbapassword=clouderadatabase=retail_dbjdbc URL = jdbc:mysql://quickstart:3306/retail_dbPlease accomplish following activities.1. In mysql departments table please insert following record. Insert into departments values(9999, '"Data Science"1);2. Now there is a downstream system which will process dumps of this file. However, system is designed the way that it can process only files if fields are enlcosed in(') single quote and separate of the field should be (-} and line needs to be terminated by : (colon).3. If data itself contains the " (double quote } than it should be escaped by \.4. Please import the departments table in a directory called departments_enclosedby and file should be able to process by downstream system.
Question34: CORRECT TEXTProblem Scenario 28 : You need to implement near real time solutions for collecting information when submitted in file with belowDataecho "IBM,100,20160104" >> /tmp/spooldir2/.bb.txtecho "IBM,103,20160105" >> /tmp/spooldir2/.bb.txtmv /tmp/spooldir2/.bb.txt /tmp/spooldir2/bb.txtAfter few minsecho "IBM,100.2,20160104" >> /tmp/spooldir2/.dr.txtecho "IBM,103.1,20160105" >> /tmp/spooldir2/.dr.txtmv /tmp/spooldir2/.dr.txt /tmp/spooldir2/dr.txtYou have been given below directory location (if not available than create it) /tmp/spooldir2.As soon as file committed in this directory that needs to be available in hdfs in/tmp/flume/primary as well as /tmp/flume/secondary location.However, note that/tmp/flume/secondary is optional, if transaction failed which writes in this directory need not to be rollback.Write a flume configuration file named flumeS.conf and use it to load data in hdfs with following additional properties .1 . Spool /tmp/spooldir2 directory2 . File prefix in hdfs sholuld be events3 . File suffix should be .log4 . If file is not committed and in use than it should have _ as prefix.5 . Data should be written as text to hdfs
Question35: CORRECT TEXTProblem Scenario 5 : You have been given following mysql database details.user=retail_dbapassword=clouderadatabase=retail_dbjdbc URL = jdbc:mysql://quickstart:3306/retail_dbPlease accomplish following activities.1. List all the tables using sqoop command from retail_db2. Write simple sqoop eval command to check whether you have permission to read database tables or not.3 . Import all the tables as avro files in /user/hive/warehouse/retail cca174.db4 . Import departments table as a text file in /user/cloudera/departments.
Question36: CORRECT TEXTProblem Scenario 75 : You have been given MySQL DB with following details.user=retail_dbapassword=clouderadatabase=retail_dbtable=retail_db.orderstable=retail_db.order_itemsjdbc URL = jdbc:mysql://quickstart:3306/retail_dbPlease accomplish following activities.1. Copy "retail_db.order_items" table to hdfs in respective directory p90_order_items .2. Do the summation of entire revenue in this table using pyspark.3. Find the maximum and minimum revenue as well.4. Calculate average revenueColumns of ordeMtems table : (order_item_id , order_item_order_id ,order_item_product_id, order_item_quantity,order_item_subtotal,order_item_subtotal,order_item_product_price)
Question37: CORRECT TEXTProblem Scenario 30 : You have been given three csv files in hdfs as below.EmployeeName.csv with the field (id, name)EmployeeManager.csv (id, manager Name)EmployeeSalary.csv (id, Salary)Using Spark and its API you have to generate a joined output as below and save as a text tile (Separated by comma) for final distribution and output must be sorted by id.ld,name,salary,managerNameEmployeeManager.csvE01,VishnuE02,SatyamE03,ShivE04,SundarE05,JohnE06,PallaviE07,TanvirE08,ShekharE09,VinodE10,JitendraEmployeeName.csvE01,LokeshE02,BhupeshE03,AmitE04,RatanE05,DineshE06,PavanE07,TejasE08,SheelaE09,KumarE10,VenkatEmployeeSalary.csvE01,50000E02,50000E03,45000E04,45000E05,50000E06,45000E07,50000E08,10000E09,10000E10,10000
Question38: CORRECT TEXTProblem Scenario 14 : You have been given following mysql database details as well as other info.user=retail_dbapassword=clouderadatabase=retail_dbjdbc URL = jdbc:mysql://quickstart:3306/retail_dbPlease accomplish following activities.1. Create a csv file named updated_departments.csv with the following contents in local file system.updated_departments.csv2 ,fitness3 ,footwear1 2,fathematics1 3,fcience1 4,engineering1 000,management2. Upload this csv file to hdfs filesystem,3. Now export this data from hdfs to mysql retaildb.departments table. During upload make sure existing department will just updated and new departments needs to be inserted.4. Now update updated_departments.csv file with below content.2 ,Fitness3 ,Footwear1 2,Fathematics1 3,Science1 4,Engineering1 000,Management2 000,Quality Check5. Now upload this file to hdfs.6. Now export this data from hdfs to mysql retail_db.departments table. During upload make sure existing department will just updated and no new departments needs to be inserted.
Question39: CORRECT TEXTProblem Scenario 45 : You have been given 2 files , with the content as given Below(spark12/technology.txt)(spark12/salary.txt)(spark12/technology.txt)first,last,technologyAmit,Jain,javaLokesh,kumar,unixMithun,kale,sparkRajni,vekat,hadoopRahul,Yadav,scala(spark12/salary.txt)first,last,salaryAmit,Jain,100000Lokesh,kumar,95000Mithun,kale,150000Rajni,vekat,154000Rahul,Yadav,120000Write a Spark program, which will join the data based on first and last name and save the joined results in following format, first Last.technology.salary
Question40: CORRECT TEXTProblem Scenario 51 : You have been given below code snippet.val a = sc.parallelize(List(1, 2,1, 3), 1)val b = a.map((_, "b"))val c = a.map((_, "c"))Operation_xyzWrite a correct code snippet for Operationxyz which will produce below output.Output:Array[(lnt, (lterable[String], lterable[String]))] = Array((2,(ArrayBuffer(b),ArrayBuffer(c))),(3,(ArrayBuffer(b),ArrayBuffer(c))),(1,(ArrayBuffer(b, b),ArrayBuffer(c, c))))
Question41: CORRECT TEXTProblem Scenario 73 : You have been given data in json format as below.{"first_name":"Ankit", "last_name":"Jain"}{"first_name":"Amir", "last_name":"Khan"}{"first_name":"Rajesh", "last_name":"Khanna"}{"first_name":"Priynka", "last_name":"Chopra"}{"first_name":"Kareena", "last_name":"Kapoor"}{"first_name":"Lokesh", "last_name":"Yadav"}Do the following activity1 . create employee.json file locally.2 . Load this file on hdfs3 . Register this data as a temp table in Spark using Python.4 . Write select query and print this data.5 . Now save back this selected data in json format.
Question42: CORRECT TEXTProblem Scenario 19 : You have been given following mysql database details as well as other info.user=retail_dbapassword=clouderadatabase=retail_dbjdbc URL = jdbc:mysql://quickstart:3306/retail_dbNow accomplish following activities.1. Import departments table from mysql to hdfs as textfile in departments_text directory.2. Import departments table from mysql to hdfs as sequncefile in departments_sequence directory.3. Import departments table from mysql to hdfs as avro file in departments avro directory.4. Import departments table from mysql to hdfs as parquet file in departments_parquet directory.
Question43: CORRECT TEXTProblem Scenario 6 : You have been given following mysql database details as well as other info.user=retail_dbapassword=clouderadatabase=retail_dbjdbc URL = jdbc:mysql://quickstart:3306/retail_dbCompression Codec : org.apache.hadoop.io.compress.SnappyCodecPlease accomplish following.1. Import entire database such that it can be used as a hive tables, it must be created in default schema.2. Also make sure each tables file is partitioned in 3 files e.g. part-00000, part-00002, part-000033. Store all the Java files in a directory called java_output to evalute the further
Question44: CORRECT TEXTProblem Scenario 87 : You have been given below three filesproduct.csv (Create this file in hdfs)productID,productCode,name,quantity,price,supplierid1 001,PEN,Pen Red,5000,1.23,5011 002,PEN,Pen Blue,8000,1.25,5011003,PEN,Pen Black,2000,1.25,5011004,PEC,Pencil 2B,10000,0.48,5021005,PEC,Pencil 2H,8000,0.49,5021006,PEC,Pencil HB,0,9999.99,5022001,PEC,Pencil 3B,500,0.52,5012002,PEC,Pencil 4B,200,0.62,5012003,PEC,Pencil 5B,100,0.73,5012004,PEC,Pencil 6B,500,0.47,502supplier.csvsupplierid,name,phone501,ABC Traders,88881111502,XYZ Company,88882222503,QQ Corp,88883333products_suppliers.csvproductID,supplierID2001,5012002,5012003,5012004,5022001,503Now accomplish all the queries given in solution.Select product, its price , its supplier name where product price is less than 0.6 usingSparkSQL
Question45: CORRECT TEXTProblem Scenario 83 : In Continuation of previous question, please accomplish following activities.1. Select all the records with quantity >= 5000 and name starts with 'Pen'2. Select all the records with quantity >= 5000, price is less than 1.24 and name starts with'Pen'3. Select all the records witch does not have quantity >= 5000 and name does not starts with 'Pen'4. Select all the products which name is 'Pen Red', 'Pen Black'5. Select all the products which has price BETWEEN 1.0 AND 2.0 AND quantityBETWEEN 1000 AND 2000.
Question46: CORRECT TEXTProblem Scenario 40 : You have been given sample data as below in a file called spark15/file1.txt3070811,1963,1096,,"US","CA",,1,3022811,1963,1096,,"US","CA",,1,563033811,1963,1096,,"US","CA",,1,23Below is the code snippet to process this tile.val field= sc.textFile("spark15/f ilel.txt")val mapper = field.map(x=> A)mapper.map(x => x.map(x=> {B})).collectPlease fill in A and B so it can generate below final outputArray(Array(3070811,1963,109G, 0, "US", "CA", 0,1, 0),Array(3022811,1963,1096, 0, "US", "CA", 0,1, 56),Array(3033811,1963,1096, 0, "US", "CA", 0,1, 23))
Question47: CORRECT TEXTProblem Scenario 34 : You have given a file named spark6/user.csv.Data is given below:user.csvid,topic,hitsRahul,scala,120Nikita,spark,80Mithun,spark,1myself,cca175,180Now write a Spark code in scala which will remove the header part and create RDD of values as below, for all rows. And also if id is myself" than filter out row.Map(id -> om, topic -> scala, hits -> 120)
Question48: CORRECT TEXTProblem Scenario 7 : You have been given following mysql database details as well as other info.user=retail_dbapassword=clouderadatabase=retail_dbjdbc URL = jdbc:mysql://quickstart:3306/retail_dbPlease accomplish following.1. Import department tables using your custom boundary query, which import departments between 1 to 25.2 . Also make sure each tables file is partitioned in 2 files e.g. part-00000, part-000023 . Also make sure you have imported only two columns from table, which are department_id,department_name
Question49: CORRECT TEXTProblem Scenario 23 : You have been given log generating service as below.Start_logs (It will generate continuous logs)Tail_logs (You can check , what logs are being generated)Stop_logs (It will stop the log service)Path where logs are generated using above service : /opt/gen_logs/logs/access.logNow write a flume configuration file named flume3.conf , using that configuration file dumps logs in HDFS file system in a directory called flumeflume3/%Y/%m/%d/%H/%MMeans every minute new directory should be created). Please us the interceptors to provide timestamp information, if message header does not have header info.And also note that you have to preserve existing timestamp, if message contains it. Flume channel should have following property as well. After every 100 message it should be committed, use non-durable/faster channel and it should be able to hold maximum 1000 events.
Question50: CORRECT TEXTProblem Scenario 50 : You have been given below code snippet (calculating an average score}, with intermediate output.type ScoreCollector = (Int, Double)type PersonScores = (String, (Int, Double))val initialScores = Array(("Fred", 88.0), ("Fred", 95.0), ("Fred", 91.0), ("Wilma", 93.0),("Wilma", 95.0), ("Wilma", 98.0))val wilmaAndFredScores = sc.parallelize(initialScores).cache()val scores = wilmaAndFredScores.combineByKey(createScoreCombiner, scoreCombiner, scoreMerger) val averagingFunction = (personScore: PersonScores) => { val (name, (numberScores, totalScore)) = personScore (name, totalScore / numberScores)}val averageScores = scores.collectAsMap(}.map(averagingFunction)Expected output: averageScores: scala.collection.Map[String,Double] = Map(Fred ->91.33333333333333, Wilma -> 95.33333333333333)Define all three required function , which are input for combineByKey method, e.g.(createScoreCombiner, scoreCombiner, scoreMerger). And help us producing required results.